﻿/**
 * 
 */
//var $remote_url_pre = 'http://192.168.0.137:8888/cake/';
//var $remote_url_pre = 'http://172.10.5.156:8888/cake/';//阿里巴巴
var $remote_url_pre = '/cake/';

var $assets = {
	headChooseIcon : $remote_url_pre + 'assets/i/head-icon.png'
}

var $html = {
	index : $remote_url_pre + 'index.html',
	login : $remote_url_pre + 'login.html'
};

/**
 * system controller api
 */
var $api = {
    index : {

    },
    admin : {
        selectSystemAdmins : $remote_url_pre + 'admin/selectSystemAdmins', //查询后台人员列表
        selectSystemAdminById : $remote_url_pre + 'admin/selectSystemAdminById', //根据id查询后台人员详情
        insertOrUpdateAdmin : $remote_url_pre + 'admin/insertOrUpdateAdmin',	//更新后台人员信息
        selectAdminMenus : $remote_url_pre + 'admin/selectAdminMenus',//查询登录人员拥有菜单
        updatePassword : $remote_url_pre + 'admin/updatePassword'//查询登录人员拥有菜单
    },
    order : {
        selectOrders : $remote_url_pre + 'order/selectOrders', //查询订单
        selectOrderByOrderId : $remote_url_pre + 'order/selectOrderByOrderId' //根据id查询订单详情
    },
    banner : {
        selectBanners : $remote_url_pre + 'banner/selectBanners',//banner列表
        selectBannerById : $remote_url_pre + 'banner/selectBannerById',//banner详情
        updateBanner : $remote_url_pre + 'banner/updateBanner',//修改banner信息
        selectProductBasicInfoForBanner : $remote_url_pre + 'banner/selectProductBasicInfoForBanner',//获取商品基本详情
        selectProductCategoryBasicInfoForBanner : $remote_url_pre + 'banner/selectProductCategoryBasicInfoForBanner'//获取商品分类基本详情
    },
    shop : {
        selectShops : $remote_url_pre + 'shop/selectShops',//查询所有的圈子
        selectShopById : $remote_url_pre + 'shop/selectShopById',//根据id查询一条圈子详情
        insertShop : $remote_url_pre + 'shop/insertShop',//添加一条圈子
        updateShop : $remote_url_pre + 'shop/updateShop'//修改一条圈子
    },
    product :{
        selectProducts : $remote_url_pre + "product/selectProducts",//初始化
        selectProductById : $remote_url_pre + "product/selectProductById",// id查询
        insertOrUpdateProduct : $remote_url_pre + "product/insertOrUpdateProduct",// 保存
    },
    productCategory : {
        selectProductCategorys : $remote_url_pre + "productCategory/selectProductCategorys",//查询所有商品分类
        selectProductCategoryById : $remote_url_pre + "productCategory/selectProductCategoryById",//根据id查询一条商品分类详情
        insertProductCategory : $remote_url_pre + "productCategory/insertProductCategory",//添加一条商品分类
        updateForProductCategory : $remote_url_pre + "productCategory/updateProductCategory",//修改一条商品分类
        checkProductCategoryCanForbidden : $remote_url_pre + "productCategory/checkProductCategoryCanForbidden",//检查商品分类是否可以禁用
        forbiddenProductCategory : $remote_url_pre + "productCategory/forbiddenProductCategory",//禁用一条商品分类
        selectProductCategorysForInsertCoupon : $remote_url_pre + "productCategory/selectProductCategorysForInsertCoupon",//禁用一条商品分类
    },
    member : {
        selectMembers : $remote_url_pre + "member/selectMembers",//查询会员信息
        selectMemberById : $remote_url_pre + "member/selectMemberById",//根据id查询一条会员详情
        updateMember : $remote_url_pre + "member/updateMember"//修改会员信息
    },
    memberBank : {
        selectMemberRanks : $remote_url_pre + "memberRank/selectMemberRanks",//查询get
        selectMemberRankById : $remote_url_pre + "memberRank/selectMemberRankById",
        insertOrUpdateMemberRank : $remote_url_pre + "memberRank/insertOrUpdateMemberRank",
        forbiddenMemberRank : $remote_url_pre + "memberRank/forbiddenMemberRank",//禁用一条会员等级
        selectMemberRanksByPage : $remote_url_pre + "memberRank/selectMemberRanksByPage"//分页post
    },
    coupon : {
        selectCoupons : $remote_url_pre + "coupon/selectCoupons",
        selectCouponById : $remote_url_pre + "coupon/selectCouponById",
        insertCoupon : $remote_url_pre + "coupon/insertOrUpdateCoupon",
        forbiddenCoupon : $remote_url_pre + "coupon/forbiddenCoupon"//禁用一条优惠券
    },
    role : {
        selectAllRoles : $remote_url_pre + 'role/selectAllRoles',	//查询所有的角色
        selectRoleById : $remote_url_pre + 'role/selectRoleById',	//根据id查询角色详情
        insertOrUpdateRole : $remote_url_pre + 'role/insertOrUpdateRole',	//添加或者保存角色
        selectFirstGradeMenus : $remote_url_pre + 'role/selectFirstGradeMenus'
    },
    login : {
        login : $remote_url_pre + 'login/loginForAdmin',//登录
        logout : $remote_url_pre + 'login/logoutForAdmin'//注销
    },
    postReview : {
        selectPosterReviews : $remote_url_pre + 'postReview/selectPosterReviews',//评论列表查询
        selectPosterReviewById : $remote_url_pre + 'postReview/selectPosterReviewById'//评论列表查询
    },
    thermodynamic : {
        thermodynamicChartForReceiverTotal : $remote_url_pre + "thermodynamic/thermodynamicChartForReceiverTotal",//收货人热力图
        thermodynamicChartForOrderTotal : $remote_url_pre + "thermodynamic/thermodynamicChartForOrderTotal",//订单数热力图
        thermodynamicChartForAmountTotal : $remote_url_pre + "thermodynamic/thermodynamicChartForAmountTotal"//销售额热力图
    }
};

/**
 * 检查请求是否正常--需要引入layui
 * @param data
 * @returns {Boolean}
 */
function $checkRemouteStatus(data) {
	if (data.status == "500" || data.code == "555555") {//由于数据问题，服务器异常
		layui.use('layer', function() {
			var layer = layui.layer;
			layer.msg(data.msg, {icon: 2});
		});
		return false;
	}else if(data.code == "111111"){//发送数据等等不合格程序检测到返回状态
		layui.use('layer', function() {
			var layer = layui.layer;
			layer.msg(data.msg, {icon: 2});
		});
		return false;
	}else if(data.code == "999999"){//没有登录
		layui.use('layer', function() {
			var layer = layui.layer;
			layer.msg(data.msg, {icon: 5});
			setTimeout('window.parent.$configToLogin();',2000);
		});
		return false;
	}
	return true;
}

/**
 * 检查form表单
 * @param formId
 * @returns
 */
function $checkFormVal(formId){
	var flg = true;
	$(formId).find('input').each(function(){
		if($(this).hasClass('am-field-error')){
			flg = false;
			return;
		}
	});
	$(formId).find('textarea').each(function(){
		if($(this).hasClass('am-field-error')){
			flg = false;
			return;
		}
	});
	return flg;
}

/**
 * 添加一个iframe tab
 * @param iframeUrl	url	
 * @param tabName	名称
 * @param iframeUuid	uuid
 * @returns
 */
function $addOneFrameTab(iframeUrl, tabName, iframeUuid){
	window.parent.$addIframeTal(iframeUrl, tabName, iframeUuid);
}
